package com.jason.www.utils;

import okhttp3.Callback;
import okhttp3.Headers;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;

/**
 * @author：Jason
 * @date：2022/3/18 14:27
 * @email：1129847330@qq.com
 * @description:
 */
public class OKHttpUtils {
    public static void post(String address, Headers headers, RequestBody requestBody, Callback callback) {
        OkHttpClient okHttpClient = new OkHttpClient();
        Request.Builder builder = new Request.Builder();
        if (headers != null) {
            builder.headers(headers);
        }
        if (requestBody != null) {
            builder.post(requestBody);
        }
        Request request = builder.url(address).build();
        okHttpClient.newCall(request).enqueue(callback);
    }
}